package com.ruoyi.labortary.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.labortary.domain.AlgsLaboratory;
import com.ruoyi.labortary.service.IAlgsLaboratoryService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * labortaryController
 * 
 * @author ruoyi
 * @date 2023-03-15
 */
@RestController
@RequestMapping("/laboratory")
public class AlgsLaboratoryController extends BaseController
{
    @Autowired
    private IAlgsLaboratoryService algsLaboratoryService;

    /**
     * 查询labortary列表
     */
//    @RequiresPermissions("labortary:laboratory:list")
    @GetMapping("/list")
    public TableDataInfo list(AlgsLaboratory algsLaboratory)
    {
        startPage();
        List<AlgsLaboratory> list = algsLaboratoryService.selectAlgsLaboratoryList(algsLaboratory);
        return getDataTable(list);
    }

    /**
     * 导出labortary列表
     */
//    @RequiresPermissions("labortary:laboratory:export")
//    @Log(title = "labortary", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlgsLaboratory algsLaboratory)
    {
        List<AlgsLaboratory> list = algsLaboratoryService.selectAlgsLaboratoryList(algsLaboratory);
        ExcelUtil<AlgsLaboratory> util = new ExcelUtil<AlgsLaboratory>(AlgsLaboratory.class);
        util.exportExcel(response, list, "labortary数据");
    }

    /**
     * 获取labortary详细信息
     */
//    @RequiresPermissions("labortary:laboratory:query")
    @GetMapping(value = "/{laboratoryId}")
    public AjaxResult getInfo(@PathVariable("laboratoryId") Long laboratoryId)
    {
        return success(algsLaboratoryService.selectAlgsLaboratoryByLaboratoryId(laboratoryId));
    }

    /**
     * 新增labortary
     */
//    @RequiresPermissions("labortary:laboratory:add")
//    @Log(title = "labortary", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlgsLaboratory algsLaboratory)
    {
        return toAjax(algsLaboratoryService.insertAlgsLaboratory(algsLaboratory));
    }

    /**
     * 修改labortary
     */
//    @RequiresPermissions("labortary:laboratory:edit")
//    @Log(title = "labortary", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlgsLaboratory algsLaboratory)
    {
        return toAjax(algsLaboratoryService.updateAlgsLaboratory(algsLaboratory));
    }

    /**
     * 删除labortary
     */
//    @RequiresPermissions("labortary:laboratory:remove")
//    @Log(title = "labortary", businessType = BusinessType.DELETE)
	@DeleteMapping("/{laboratoryIds}")
    public AjaxResult remove(@PathVariable Long[] laboratoryIds)
    {
        return toAjax(algsLaboratoryService.deleteAlgsLaboratoryByLaboratoryIds(laboratoryIds));
    }
}
